package sctu.edu.java.year2016.team03.liyouhong.day20160521.chapter4_3;

/**
 * Created by Administrator on 2016/5/21 0021.
 * 3.编写java程序，使用while循环语句计算1+1/2!+....+1/20!之和。
 */
public class Recursion {
    public static void main(String[] args) {

        int i = 1;
       double sum = 0d;
        int a=1;
        while (i <= 20) {
            sum +=1/(double)mysum(i);
                    i++;
        }
        System.out.println(sum);
        }

    public static int mysum(int n){
        if(n==1)
          return 1;
        else
            return   mysum(n-1)*n;

    }
    }
